import request from '@/config/axios'
import type { RegionData } from './types'

export const getRegionListApi = (params: any): Promise<IResponse> => {
    const queryParams = params.queryParams ? params.queryParams : {}
    if (params.queryParams) {
        delete params.queryParams
    }
    Object.assign(params, queryParams)
    return request.get({url: '/balance/region/page', params})
}

export const saveOrUpdateRegionApi = (data: Partial<RegionData>, isUpdate = false): Promise<IResponse> => {
    data.id = "";
    if(isUpdate) {
        return request.post({url: '/balance/region/edit', data})
    }else {
        return request.post({url: '/balance/region/save', data})
    }
}

export const getRegionDetailApi = (data: Partial<RegionData>): Promise<IResponse<RegionData>> => {
    return request.get({url: '/balance/region/info', params: data})
}

export const delRegionListApi = (data: Partial<RegionData>[]): Promise<IResponse> => {
    return request.post({url: '/balance/region/delete', data})
}

export const regionDisableApi = (data: Partial<RegionData>): Promise<IResponse> => {
    return request.post({url: '/balance/region/disable', data})
}
export const regionEnableApi = (data: Partial<RegionData>): Promise<IResponse> => {
    return request.post({url: '/balance/region/enable', data})
}
